package v1

import (
	"devops-super/api"
	"devops-super/internal/model/entity"
	"github.com/gogf/gf/v2/frame/g"
)

// ClusterConfigGetPageLstReq 分页获取集群配置列表请求
type ClusterConfigGetPageLstReq struct {
	g.Meta `method:"get" path:"/cluster-config/page-list" summary:"分页获取集群配置列表" tags:"集群配置"`
	*api.PageLstReq
}

// ClusterConfigGetPageLstRes 分页获取集群配置列表响应
type ClusterConfigGetPageLstRes struct {
	*api.PageLstRes[*entity.AppClusterServerConfig]
}

// ClusterConfigAddReq 新增集群配置请求
type ClusterConfigAddReq struct {
	g.Meta       `method:"post" path:"/cluster-config" summary:"新增集群配置" tags:"集群配置"`
	ServerKey    int64  `v:"required#服务器key不能为空" json:"serverKey"`
	GroupName    string `v:"required#配置组名不能为空" json:"groupName"`
	ConfigKey    string `v:"required#配置键不能为空" json:"configKey"`
	ConfigValue  string `v:"required#配置值不能为空" json:"configValue"`
	Remark       string `json:"remark"`
}

// ClusterConfigAddRes 新增集群配置响应
type ClusterConfigAddRes struct {}

// ClusterConfigUptReq 更新集群配置请求
type ClusterConfigUptReq struct {
	g.Meta       `method:"put" path:"/cluster-config/{id}" summary:"更新集群配置" tags:"集群配置"`
	Id           int64  `v:"min:1#配置ID必须" path:"id"`
	ServerKey    int64  `v:"required#服务器key不能为空" json:"serverKey"`
	GroupName    string `v:"required#配置组名不能为空" json:"groupName"`
	ConfigKey    string `v:"required#配置键不能为空" json:"configKey"`
	ConfigValue  string `v:"required#配置值不能为空" json:"configValue"`
	Remark       string `json:"remark"`
}

// ClusterConfigUptRes 更新集群配置响应
type ClusterConfigUptRes struct {}

// ClusterConfigDelReq 删除集群配置请求
type ClusterConfigDelReq struct {
	g.Meta `method:"delete" path:"/cluster-config/{id}" summary:"删除集群配置" tags:"集群配置"`
	Id     int64 `v:"min:1#配置ID必须" path:"id"`
}

// ClusterConfigDelRes 删除集群配置响应
type ClusterConfigDelRes struct {}

// ClusterConfigGetOneReq 获取单条集群配置请求
type ClusterConfigGetOneReq struct {
	g.Meta `method:"get" path:"/cluster-config/getOne" summary:"获取单条集群配置" tags:"集群配置"`
	Id     int64 `v:"min:1#配置ID必须" json:"id"`
}

// ClusterConfigGetOneRes 获取单条集群配置响应
type ClusterConfigGetOneRes struct {
	Info *entity.AppClusterServerConfig `json:"info"`
}

// ClusterConfigGetOptionsReq 获取集群配置选项请求
type ClusterConfigGetOptionsReq struct {
	g.Meta     `method:"get" path:"/cluster-config/getOptions" summary:"获取集群配置选项" tags:"集群配置"`
	FieldKey   string `json:"fieldKey"`   // 自定义value字段
	FieldLabel string `json:"fieldLabel"` // 自定义label字段
	ServerKey  int64  `json:"serverKey"`  // 服务器key筛选
	GroupName  string `json:"groupName"`  // 配置组名筛选
}

// ClusterConfigGetOptionsRes 获取集群配置选项响应
type ClusterConfigGetOptionsRes struct {
	Options []*api.FormOptionsItem `json:"options"`
}

// GetClusterGroupConfigsReq 获取集群配置组请求
type GetClusterGroupConfigsReq struct {
	g.Meta    `method:"get" path:"/cluster-config/getGroupConfigs" summary:"获取集群配置组" tags:"集群配置"`
	ServerKey int    `v:"min:1#服务器ID必须" json:"serverKey" in:"query"`
	GroupName string `v:"required#配置组名必须" json:"groupName" in:"query"`
}

// GetClusterGroupConfigsRes 获取集群配置组响应
type GetClusterGroupConfigsRes struct {
	Configs   []*entity.AppClusterServerConfig `json:"configs"`
	UpdatedAt string                           `json:"updatedAt"`
}

// SetClusterGroupConfigsReq 保存集群配置组请求
type SetClusterGroupConfigsReq struct {
	g.Meta    `method:"post" path:"/cluster-config/setGroupConfigs" summary:"保存集群配置组" tags:"集群配置"`
	ServerKey int    `v:"min:1#服务器ID必须" json:"serverKey"`
	GroupName string `v:"required#配置组名必须" json:"groupName"`
	Configs   []struct {
		ConfigKey   string `v:"required#配置键必须" json:"configKey"`
		ConfigValue string `v:"required#配置值必须" json:"configValue"`
		ConfigDesc  string `json:"configDesc"`
	} `v:"required#配置项不能为空" json:"configs"`
}

// SetClusterGroupConfigsRes 保存集群配置组响应
type SetClusterGroupConfigsRes struct {}